import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  //组件共享的数据, 类似组件的data
  //根的state
  state: {
    activeIndex: 0,
    name: '',
    CellPhoneNumber: '',
    password: '',
    ifEavr: false,
    ifEavrOne: true,
    like: [],
    play: [],
    collectionGedan: [],
    collectionGedanTextOne: '收藏',
    collectionGedanTextTwo: '已收藏',
    collectionZhuanji: [],
    collectionGeshou: [],
    now: [],
    zon: [],
    mp3: '',
    id: '',
    isPlay: false, // 是否播放
    picUrl: '',
    urlname: 'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fpic.51yuansu.com%2Fpic3%2Fcover%2F01%2F91%2F43%2F59829d955c0aa_610.jpg&refer=http%3A%2F%2Fpic.51yuansu.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1655292815&t=a9d0c49994018f5fb82151f1782437cc',
    Lyric: '',
    historyindex: ['你', '爱'],
  },
  mutations: {
    update(state, payload) {
      state.zon.push(payload.data);
      // console.log('state.zon==>', state.zon);
    },
    updateActiveIndex(state, payload) {
      state.activeIndex = payload.data;
      // console.log('state.zon==>', state.zon);
    },
    updateOne(state, payload) {
      state.mp3 = payload.data;
      // console.log('state.mp3==>', state.mp3);
      // this.$refs.audio.play();
    },
    updateI(state, payload) {
      state.urlname = payload.data;
      // console.log('state.mp3==>', state.mp3);
      // this.$refs.audio.play();
    },
    updateL(state, payload) {
      state.picUrl = payload.data;
      // console.log('state.mp3==>', state.mp3);
      // this.$refs.audio.play();
    },
    updateTwo(state, payload) {
      state.id = payload.data;
      // console.log('state.id==>', state.id);
      // this.$refs.audio.play();
    },
    updateLyric(state, payload) {
      state.Lyric = payload.data;
      // console.log('state.id==>', state.id);
      // this.$refs.audio.play();
    },
    updateshanchu(state, payload) {
      state.zon.splice(payload.data, 1);
      // console.log('state.zon==>', state.zon);
      // console.log('state.id==>', state.id);
      // this.$refs.audio.play();
    },
    updatehistoryindex(state, payload) {
      state.historyindex.unshift(payload.data);
      // this.$refs.audio.play();
    },
    updateshift(state, payload) {
      state.historyindex.splice(payload.data , 1);
      // console.log('payload.data==>', payload.data);
      // console.log('state.historyindex==>', state.historyindex);
      // console.log('state.id==>', state.id);
      // this.$refs.audio.play();
    }
  }
})
